package com.example.util.websocket;

import com.example.vo.websocket.ResultMassage;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * websocket工具类
 *
 * @author wsl
 */
public class MessageUtils {

    public static String getMessage(boolean isSystemMessage,String formName,Object message){
        try {
            ResultMassage result = new ResultMassage();
            result.setMessage(message);
            result.setIsSystem(isSystemMessage);
            if(formName!=null){
                result.setFromName(formName);
            }
            ObjectMapper mapper = new ObjectMapper();
            return mapper.writeValueAsString(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
